package com.droowa.model.service;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.droowa.domain.DeliveryEnterpriseManagement;
import com.droowa.model.dao.DeliveryEnterpriseManagementDAO;

@Service
public class DeliveryEnterpriseManagementServiceImpl implements DeliveryEnterpriseManagementService{

	@Autowired
	private DeliveryEnterpriseManagementDAO dao;
	
	@Override
	public int joinDeliveryEnterpriseManagement(
			DeliveryEnterpriseManagement deliveryEnterpriseManagement)
			throws SQLException {
		if(getDeliveryEnterpriseManagement()!=null){
			int update = modifyDeliveryEnterpriseManagement(deliveryEnterpriseManagement);
			if(update==1){
				return -1;
			}else{
				return 0;
			}
		}
		return dao.insertDeliveryEnterpriseManagement(deliveryEnterpriseManagement);
	}

	@Override
	public int removeDeliveryEnterpriseManagement(String deliveryEnterpriseId)
			throws SQLException {
		return dao.deleteDeliveryEnterpriseManagement(deliveryEnterpriseId);
	}

	@Override
	public int modifyDeliveryEnterpriseManagement(
			DeliveryEnterpriseManagement deliveryEnterpriseManagement)
			throws SQLException {
		return dao.updateDeliveryEnterpriseManagement(deliveryEnterpriseManagement);
	}

	@Override
	public DeliveryEnterpriseManagement getDeliveryEnterpriseManagementByDeliveryEnterpriseId(
			int deliveryEnterpriseId) throws SQLException {
		return dao.selectDeliveryEnterpriseManagementByDeliveryEnterpriseId(deliveryEnterpriseId);
	}

	@Override
	public List<DeliveryEnterpriseManagement> getDeliveryEnterpriseManagementByEnterpriseName(
			String enterpriseName) throws SQLException {
		return dao.selectDeliveryEnterpriseManagementByEnterpriseName(enterpriseName);
	}

	@Override
	public List<DeliveryEnterpriseManagement> getDeliveryEnterpriseManagementByTel(
			String tel) throws SQLException {
		return dao.selectDeliveryEnterpriseManagementByTel(tel);
	}

	@Override
	public List<DeliveryEnterpriseManagement> getDeliveryEnterpriseManagementByEmail(
			String email) throws SQLException {
		return dao.selectDeliveryEnterpriseManagementByEmail(email);
	}

	@Override
	public List<DeliveryEnterpriseManagement> getDeliveryEnterpriseManagement()
			throws SQLException {
		return dao.selectDeliveryEnterpriseManagement();
	}

}
